package com.buding.fx;

import io.netty.util.NettyRuntime;
import io.netty.util.internal.SystemPropertyUtil;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.SingleSelectionModel;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author mingdongwei-jwk
 * @date 2022/11/15 10:22
 * @class com.buding.fx
 * @Description
 */
public class MainTest extends Application {
    public static void main(String[] args) {
        launch(args);
        Long a = 6552374l;
        Long b = 6552374l;
        System.out.println(a.equals(b));
    }

    @Override
    public void start(Stage primaryStage) throws Exception {



        ChoiceBox<String> c2 = new ChoiceBox<String>();//也是一个 List集合
        List<String> list2 = Arrays.asList("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16");
        c2.getItems().addAll(list2);
        c2.getSelectionModel().select(0);
        c2.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
                c2.getSelectionModel().select(newValue);
            }
        });

        Button addButton = new Button("加");
        addButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                SingleSelectionModel<String> selectionModel = c2.getSelectionModel();
                int i = selectionModel.getSelectedIndex()+1;
                selectionModel.select(i);
            }
        });

        Button reserveButton = new Button("减");
        FlowPane flowPane = new FlowPane();
        flowPane.setPrefHeight(50);
        flowPane.setPrefWidth(100);
        flowPane.getChildren().addAll(addButton,reserveButton,c2);
        Scene scene = new Scene(flowPane);
        primaryStage.setScene(scene);
        primaryStage.setResizable(false);
        primaryStage.show();
    }
}
